using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;
using System.IO;
using System.Text;

namespace DslEditorPowerToy.Installers
{
    /// <summary>
    /// Launches a file or URL
    /// </summary>
    [RunInstaller(false)]
    public partial class LaunchFileInstaller : Installer
    {
        #region Constructors
        public LaunchFileInstaller() : base()
        {
        }
        #endregion

        #region Public Methods
        public override void Commit(System.Collections.IDictionary savedState)
        {
            base.Commit(savedState);

            //Get full file path
            string filePath = base.Context.Parameters["FilePath"];
            if (null == filePath)
                return;

            //Ensure file exists
            if (false == File.Exists(filePath))
                return;

            //Execute file 
            Process.Start(filePath);
        }
        #endregion
    }
}
